<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>电影后台管理</title>
  <link href="css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
  <link href="css/font-awesome.css?v=4.4.0" rel="stylesheet">
  <link href="css/animate.css" rel="stylesheet">
  <link href="css/style.css?v=4.1.0" rel="stylesheet">
  <script>if (window.top !== window.self) { window.top.location = window.location; }</script>
</head>

<body class="gray-bg">

  <div class="middle-box text-center loginscreen  animated fadeInDown">
    <div>
      <div>
        <h1 class="logo-name">H+</h1>
      </div>
      <h3>后台登录</h3>

      <form class="m-t" role="form" onsubmit="return dopost()">
        <div class="form-group">
          <input type="text" id="username" value="wuqisong" class="form-control" placeholder="用户名">
        </div>
        <div class="form-group">
          <input type="text" id="password" value="wuqisong" class="form-control" placeholder="密码">
        </div>
        <button type="submit" class="btn btn-primary block full-width m-b">登 录</button>
      </form>
    </div>
  </div>

  <!-- 全局js -->
  <script src="js/jquery.min.js?v=2.1.4"></script>
  <script src="js/bootstrap.min.js?v=3.3.6"></script>
  <script>
    function dopost() {
      let username = $.trim($('#username').val())
      let password = $.trim($('#password').val())

      if (username != '' && password != '') {
        $('.btn').hide()
        ajax(username, password)
      }
      return false;
    }

    function ajax(username, password) {
      $.post('/admin/login', {
        username,
        password
      }).then(res => {
        if (res.code == 0) {
          location.href = '/admin/index'
        } else {
          alert(res.msg)
        }
      }, () => {
        $('.btn').show()
      })
    }
  </script>
</body>

</html>